package Models;

import DB.DBCheckpoint;
import DB.DBLocation;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
// #[regen=yes,id=DCE.27D8AB9B-383E-7AB4-9B0F-8D62EFE46753]
// </editor-fold> 
public class Round extends DB.RowAbstract
{
	// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
	// #[regen=yes,id=DCE.08079571-6309-16CA-A6FB-382B1C5AEA9C]
	// </editor-fold> 
	private int roundNo;

	private Location location;

	// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
	// #[regen=yes,id=DCE.A8D91030-067D-6C0F-17FC-4E322B9AD803]
	// </editor-fold> 
	private ArrayList<Checkpoint> checkpoints;

	// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
	// #[regen=yes,id=DCE.011F7274-E37B-FA4E-1E77-56EEF60CCEAF]
	// </editor-fold> 
	public Round ()
	{}

	public void importData(ResultSet data) throws SQLException
	{
		this.setRoundNo(data.getInt("roundNo"));
		this.fetchDependentData(data.getInt("locationNo"));
	}

	public void fetchDependentData(int locationNo)
	{
		DBLocation dbl = new DBLocation();
		this.setLocation(dbl.fetchRow("locationNo = "+locationNo, null));
		DBCheckpoint dbc = new DBCheckpoint();
		this.setCheckpoints(dbc.fetchAll("roundNo = "+roundNo, null, 0));
	}

	public static String[] getSearchColumns()
	{
		return new String[] { "roundNo" };
	}

	// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
	// #[regen=yes,regenBody=yes,id=DCE.33ABD1A1-DDFF-113D-B165-CC1955F8C502]
	// </editor-fold> 
	public ArrayList<Checkpoint> getCheckpoints () {
		return checkpoints;
	}

	// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
	// #[regen=yes,regenBody=yes,id=DCE.DB51EC96-EF70-6F62-29C0-9EED58AD2400]
	// </editor-fold> 
	public void setCheckpoints (ArrayList<Checkpoint> val) {
		checkpoints = val;
	}

	public Location getLocation()
	{
		return location;
	}

	public void setLocation(Location location)
	{
		this.location = location;
	}

	// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
	// #[regen=yes,regenBody=yes,id=DCE.C9F06769-DAB0-5F59-B2EF-160FB38F12C3]
	// </editor-fold> 
	public int getRoundNo () {
		return roundNo;
	}

	// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
	// #[regen=yes,regenBody=yes,id=DCE.7A0AF255-DEB8-2718-823C-030851AB7DF5]
	// </editor-fold> 
	public void setRoundNo (int val) {
		roundNo = val;
	}
}